//19 normal
function removeNthFromEnd(head, n) {
  let cur = head;
  let nth = head;
  for (let i = 0; i < n; i++) {
    if (nth === null) {
      return head.next;
    }
    nth = nth.next;
  }
  while (nth !== null) {
    cur = cur.next;
    nth = nth.next;
  }
  cur.next = cur.next.next;
  return head;
}
